package com.framework.common.enums;

/**
 * 根据val获取 枚举实体
 *
 * @author lihanbo
 * @version 1.0
 * @date 2021/11/30 11:35
 */
public class IEnumUtils {
    public static <E extends IEnum> E getEnumByKey(String val, Class<E> clazz) {
        for (final E e : clazz.getEnumConstants()) {
            if (e.getVal().equals(val)) {
                return e;
            }
        }
        throw new RuntimeException("枚举不存在");
    }

    public static void main(String[] args) {
//        DeleteEnum enumByKey = getEnumByKey("0", DeleteEnum.class);
    }
}
